﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeCamp12.DAL;
using CodeCamp12.Domain;
using log4net;

namespace CodeCamp12.BLL
{
    public class TimeSlotBL
    {
        private ILog log = LogManager.GetLogger("CodeCamp12.BLL");

        /// <summary>
        /// Inserts new time slot
        /// </summary>
        /// <param name="timeSlot"></param>
        public void InsertTimeSlot(TimeSlots timeSlot)
        {
            var dataProvider = new TimeSlotsDataManagement();

            try
            {
                dataProvider.InsertTimeSlot(timeSlot);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }

        /// <summary>
        /// Returns all time slots for event with id passed in parametars
        /// </summary>
        /// <param name="eventId"></param>
        /// <returns></returns>
        public List<TimeSlots> GetTimeSlotsForEvent(Guid eventId)
        {
            var dataProvider = new TimeSlotsDataManagement();
            try
            {
                return dataProvider.GetTimeSlotsForEvent(eventId);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }

            return null;
        }

        /// <summary>
        /// Returns all time slots that are put in track with id passed in parametars
        /// </summary>
        /// <param name="trackId"></param>
        /// <param name="eventId"></param>
        /// <returns></returns>
        public List<TimeSlots> GetTimeSlotsForTrack(Guid trackId, Guid eventId)
        {
            var dataProvider = new TimeSlotsDataManagement();
            try
            {
                return dataProvider.GetTimeSlotsForTrack(trackId, eventId);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }

            return null;
        }

        /// <summary>
        /// Deletes time slot for event
        /// </summary>
        /// <param name="timeSlot"></param>
        public void DeleteTimeSlot(TimeSlots timeSlot)
        {
            var dataProvider = new TimeSlotsDataManagement();
            try
            {
                dataProvider.DeleteTimeSlot(timeSlot);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }
        
        /// <summary>
        /// Inserts the visitor impressions pages
        /// </summary>
        /// <param name="eventId"></param>
        /// <param name="keynoteLink"></param>
        /// <param name="breakLink"></param>
        public void UpdateTimeSlot(Guid eventId, string keynoteLink, string breakLink)
        {
            var dataProvider = new TimeSlotsDataManagement();
            try
            {
                dataProvider.UpdateTimeSlot(eventId, keynoteLink, breakLink);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw;
            }
        }
    }
}
